<template>
  <BasicModal
    v-bind="$attrs"
    @register="registerModal"
    :showCancelBtn="false"
    showFooter
    @cancel="close"
    @ok="close"
    title="详情"
    width="50%"
  >
    <Description
      class="p-4"
      size="middle"
      :column="3"
      :bordered="false"
      :data="info"
      :schema="refundSchema"
    />
  </BasicModal>
</template>
<script lang="ts">
  import { defineComponent, ref } from 'vue';
  import { Description } from '/@/components/Description/index';

  import { refundSchema } from './msg.data';

  import { BasicModal, useModalInner } from '/@/components/Modal';

  import { RECVApi } from '/@/api/sys/msg';

  export default defineComponent({
    name: 'MsgModal',
    components: { BasicModal, Description },
    emits: ['success', 'register'],
    setup(_, { emit }) {
      const info = ref({});
      const [registerModal, { closeModal }] = useModalInner(async (data) => {
        info.value = data.record;
        if (data.record.remindStatus === 0) {
          await RECVApi(data?.record.remindMsgId as string);
        }
      });

      function close() {
        closeModal();
        emit('success');
      }
      return {
        registerModal,
        info,
        refundSchema,
        close,
        // treeData,
      };
    },
  });
</script>
